#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:jidi
@file:session_http_api.py
@time:2022/08/15
"""
import requests

from homework.litemall.model.user import User
from homework.litemall.model.session import Session


class SessionHttpApi(Session):
    def refresh_token(self, user: User):
        # log.debug("portal ", portal)

        r = requests.post(
            'https://litemall.hogwarts.ceshiren.com/wx/auth/login',
            json={
                'username': user.username,
                'password': user.password
            }
        )
        # log.debug("返回值: ", (eval(r.text))['data'])
        return (eval(r.text))['data']['token']


